1. Technology Field
The present invention generally relates to a memory management method, in particular, to a block management method for managing a large number of physical blocks in a flash memory with limited system resources and a flash memory controller and a flash memory storage system using the same.
2. Description of Related Art
Along with the widespread of digital cameras, camera phones, MP3, and MP4 in recently years, the consumers' demand to storage media has increased drastically too. Flash memory is one of the most adaptable memories for such portable multi-media devices due to its characteristics such as data non-volatility, low power consumption, small volume, and non-mechanical structure. Besides being applied in foregoing portable devices, flash memory is also broadly applied to external products such as flash cards and flash drives. Thereby, flash memory has become one of the most focused electronic products in recent years and the development thereof is going toward high storage capacity and long lifespan.
When a memory cell in a flash memory is programmed, the state thereof can only be changed unidirectionally (for example, from “1” to “0”). Thus, while writing data into a block of a flash memory, the block has to be erased before being programmed. Generally speaking, physical blocks in a flash memory include data physical blocks which record valid data and no-data physical blocks which record no data or the data recorded therein has been marked as invalid data. While writing data into a flash memory, the flash memory storage system substitutes data physical blocks which contain old data with no-data physical blocks, so as to improve the programming (i.e. writing and erasing) efficiency. Since the physical blocks which are used for actually recording data are alternated continuously (i.e. the substitution between data physical blocks and no-data physical blocks), logical blocks of the flash memory are assigned in the flash memory storage system and which are mapped to the continuously substituted physical blocks to be accessed by the flash memory storage system.
In order to manage the mappings between the logical blocks and the physical blocks in a flash memory with limited system resources, the physical blocks in the flash memory are usually grouped into a plurality of logical zones, and the physical blocks are usually grouped into a plurality of physical zones. FIG. 1 is a diagram illustrating how logical blocks and physical blocks are respectively grouped into corresponding logical zones and physical zones according to a conventional technique. Referring to FIG. 1, the logical zones LZ1, LZ2, . . . , and LZP are respectively corresponding to the physical zones PZ1, PZ2, . . . , and PZP, and the logical blocks in each of the logical zones LZ1, LZ2, . . . , and LZP are only corresponding to the physical blocks in the corresponding physical zone PZ1, PZ2, . . . , or PZP, and the data physical blocks and no-data physical blocks in each physical zone are only alternatively substituted in this physical zone. For example, the logical blocks 1-1˜1-k are only corresponding to the physical blocks 1-0˜1-L, and the data physical blocks and the no-data physical blocks in the physical zone PZ1 are only alternatively substituted in the physical blocks 1-0˜1-L. In other words, in management of blocks, each logical zone and the corresponding physical zone are operated independently. Thereby, when the flash memory storage system is about to write data into a flash memory, only the logical zone for writing the data and the corresponding physical zone thereof are managed.
However, according to a conventional block management method, when a particular logical zone is accessed for the first time every time after the flash memory storage system is re-started or turned on, the flash memory storage system has to spend a lot of time to establish the mapping relationship between each logical zone and the corresponding physical zone.
Moreover, when the number of damaged physical blocks in a physical zone exceeds a particular number and accordingly there is not enough no-data physical blocks for the substitution, the physical blocks in the entire physical zone cannot be used for storing data any more. As a result, the production yield may be reduced or insufficient available storage space of the flash memory storage system may be caused.
Furthermore, when the logical blocks in a particular logical zone are accessed frequently, the erasing number of the physical blocks in the physical zone corresponding to the logical zone will be increased and accordingly the lifespan of the physical blocks in the corresponding physical zone will be shortened.